﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Windows.Media;

namespace OnTheWay.Functions
{
    public class Function : INotifyPropertyChanged
    {
        private string mName;
        private string strUrl;
        private string strImgUrl = "";
        private ImageSource mIcon;
        private Color mThemeColor;

        /// <summary>
        /// 图标路径
        /// </summary>
        public string ImgUrl
        {
            get { return strImgUrl; }
            set { strImgUrl = value; }
        }

        /// <summary>
        /// 功能模块名称
        /// </summary>
        public string Name
        {
            get { return mName; }
            set
            {
                if (!object.Equals(mName, value))
                {
                    mName = value;
                    NotifyPropertyChanged("Name");
                }
            }
        }

        /// <summary>
        /// 功能模块路径
        /// </summary>
        public string Url
        {
            get { return strUrl; }
            set { strUrl = value; }
        }

        /// <summary>
        /// 图标源
        /// </summary>
        public ImageSource Icon
        {
            get { return mIcon; }
            set
            {
                if (!object.Equals(mIcon, value))
                {
                    mIcon = value;
                    NotifyPropertyChanged("Icon");
                }
            }
        }

        /// <summary>
        /// 主题颜色
        /// </summary>
        public Color ThemeColor
        {
            get { return mThemeColor; }
            set
            {
                if (!object.Equals(mName, value))
                {
                    mThemeColor = value;
                    NotifyPropertyChanged("ThemeColor");
                }
            }
        }

        /// <summary>
        /// 构造函数
        /// </summary>
        public Function()
        {
        }

        /// <summary>
        /// 带参数的构造函数
        /// </summary>
        /// <param name="FUrl">功能模块地址</param>
        public Function(string FUrl)
        {
            this.Url = FUrl;
        }

        /// <summary>
        /// 带参数的构造函数
        /// </summary>
        /// <param name="FName">功能名称</param>
        /// <param name="FIcon">图标</param>
        /// <param name="FColor">颜色</param>
        public Function(string FName, ImageSource FIcon, Color FColor)
        {
            this.Name = FName;
            this.Icon = FIcon;
            this.ThemeColor = FColor;
        }

        /// <summary>
        /// 带参数的构造函数
        /// </summary>
        /// <param name="FName">功能名称</param>
        /// <param name="FUrl">功能模块地址</param>
        /// <param name="FIcon">图标</param>
        public Function(string FName, string FUrl, ImageSource FIcon)
        {
            this.Name = FName;
            this.Url = FUrl;
            this.Icon = FIcon;
        }

        /// <summary>
        /// 带参数的构造函数
        /// </summary>
        /// <param name="FName">功能名称</param>
        /// <param name="FUrl">功能模块地址</param>
        /// <param name="FIcon">图标</param>
        /// <param name="FColor">颜色</param>
        public Function(string FName, string FUrl, ImageSource FIcon, Color FColor)
        {
            this.Name = FName;
            this.Url = FUrl;
            this.Icon = FIcon;
            this.ThemeColor = FColor;
        }

        /// <summary>
        /// 实现通知事件接口
        /// </summary>
        /// <param name="info">属性名称</param>
        public virtual event PropertyChangedEventHandler PropertyChanged;
        private void NotifyPropertyChanged(String info)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(info));
            }
        }
    }
}
